/*
 * 文件说明: API 验证用户
 * @author: 无所谓 yagqfhd@qq.com
 * @since: 2023-12-20
 * @file: index.ts
 * @version: 0.0.1
 *
 **/

import request from "@/utils/request";
import { authUrl } from "../api-url"


/** 用户登录API */
export function loginApi(data: TAuth.LoginParams) {
    return request<TAuth.LoginResult>({
        url: authUrl.login,
        method: "post",
        data
    });
}

/** 获取用户信息API
 *
 */
export function getUserInfoApi(_token: TAuth.GetUsrInfoParams) {
    return request<TAuth.GetUserInfoResult>({
        url: authUrl.getUserInfo,
        method: "get",
    });
}


/** 获取登录用户的角色集合 */
export function getUserRolesApi(_token: TAuth.GetUserRolesParams) {
    return request<TAuth.GetUserRolesResult>({
        url: authUrl.getUserRoles,
        method: "get",
        
    });
}

/** 登录用户Token超时后刷新TokenAPI */
export function refreshTokenApi(token: TAuth.RefreshTokenParams) {
    return request<TAuth.RefreshTokenResult>({
        url: authUrl.refreshToken,
        method: "post",
        data: {
            refresh_token: token.refresh_token
        }
    });
}

/** 用户登出API */
export function logoutApi(_token: TAuth.LogoutParams) {
    return request<TAuth.LogoutResult>({
        url: authUrl.logout,
        method: "post",
    });
}

/** 修改用户密码API */
export function resetPasswordApi(params: TAuth.ResetPasswordParams){
    return request<TAuth.ResetPasswordResult>({
        url: authUrl.resetPassword,
        method: 'post',
        data: params
    })
}